<template>
  <div class="home">
    <div class="detail" v-if="detail">
      <el-image class="banner" :src="detail.banner"></el-image>
      <div class="detail-info">
        <div class="name">{{ detail.name }}</div>
        <div class="desc">{{ detail.description }}</div>
        <div class="meta">
          <i class="el-icon-time"></i> 更新时间：{{ detail.createTimeText }} |
          报告数量 {{ detail.file_count }}
        </div>
        <div class="meta">
          特色标签：<span class="tag">{{ detail.tag }}</span>
        </div>
      </div>
    </div>
    <div class="files">
      <div class="file" v-for="(item, index) in files" :key="index">
        <img class="icon" src="@/assets/images/pdf-icon.png"></img>
        <a target="_blank" :href="'/detail/' + item.id" > {{ item.name }}</a>
        <div class="time">【{{item.time_text}}】</div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  getCollectionDetail,
  getCollectionFileList,
} from "@/api/collection.js";

export default {
  name: "collection",
  components: {},
  data() {
    return {
      params: {
        page: 1,
        pageSize: 20,
        id: "",
      },
      files: [],
      detail: "",
    };
  },
  created() {
    this.params.id = this.$route.query.id;
    if (process.client) {
      this.getDetail();
      this.getFileList();
    }
  },
  methods: {
    getDetail() {
      getCollectionDetail({ id: this.params.id }).then((res) => {
        console.log(res);
        this.detail = res.data;
      });
    },
    getFileList() {
      getCollectionFileList(this.params).then((res) => {
        console.log(res);
        this.files = res.data.items;
        this.listTotal = res.data.total;
      });
    },
  },
};
</script>

<style lang="less" scoped>
.home {
  width: 100%;
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 40px 0;
}

.detail {
  width: 100%;
  max-width: 1250px;
  display: flex;
  align-items: center;
  background: white;
  padding: 20px;
  height: 210px;
}

.banner {
  width: 250px;
  height: 170px;
}

.detail-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  margin-left: 20px;
}
.name {
  font-size: 22px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #333333;
  line-height: 30px;
}

.desc {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: initial;
  font-size: 12px;
  color: #777777;
}

.meta {
  font-size: 12px;
  color: #999;
}
.tag {
  font-size: 12px;
  color: #999;
  border-width: 1px;
  border-style: solid;
  border-radius: 12px 12px 12px 0;
  background-color: #ecf5ff;
  border-color: #d9ecff;
  height: 32px;
  padding: 0 10px;
  line-height: 30px;
  font-size: 12px;
}

.files {
  width: 100%;
  max-width: 1250px;
  background: white;
  padding: 20px;
}

.file {
  display: flex;
  align-items: center;
  line-height: 1.5;
  font-size: 14px;
  color: #333;
  text-decoration: none;
  height: 40px;
  border-bottom: 1px solid #ecf5ff;
}
a {
  color: #333;
  text-decoration: none;
}
a:hover {
  color: #467dd0;
}
.icon {
  width: 18px;
  height: 16px;
  margin-right: 6px;
}

.time {
  color: #777777;
}
</style>
